import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
    state: {
        isLogin: false,
        tokenInfo:{
            token:null,
            clientid:null
        },
        examuserInfo:{

        }
    },
    getters: {},
    mutations: {
        changeUser(state, data){
            state.examuserInfo = data;
            localStorage.setItem('examuserInfo',JSON.stringify(data));
        },
        changeInLogin(state, code) {
            if (code == 200) {
                state.isLogin = true
                localStorage.setItem('isLogin', state.isLogin)
            } else {
                return null
            }
        },
        changeToken(state, data) {
            state.tokenInfo.token = data.access_token
            state.tokenInfo.clientid = data.client_id
            localStorage.setItem('tokenInfo', JSON.stringify(state.tokenInfo))
        }
    },
    actions: {},
    modules: {}
})
